<?php
/**
* @package controller
* @file indexController.php
* @date 15.09.2009
* @version 1.0
* @copyright sample
* @author Harinath Reddy
* @todo phpDoc comments
*/
require_once 'Zend/Controller/Action.php';

class album_SettingsController extends Cms_Controller_Action
{
	public function init()
	{
	  $this->view->siteTitle = 'Photos/Videos';
	  $this->currentPage = 1;
	  $this->resultsPerPage = 8;
			
	}
	public function indexAction()
	{
	  	
			
	}
	public function albumSettingsAction()
	{
	  		$memid = $_SESSION["sess_userid"];
			$type1="Facebook";
			$type2="Google";
			$type3="MySpace";
			$type4="Others";
			$result1= Doctrine::getTable('AlbumSettings')->getSettings($memid,$type1);
			$result2= Doctrine::getTable('AlbumSettings')->getSettings($memid,$type2);
			$result3= Doctrine::getTable('AlbumSettings')->getSettings($memid,$type3);
			$result4= Doctrine::getTable('AlbumSettings')->getSettings($memid,$type4);
			//echo '<pre>';print_r($result1);exit;
			$this->view->facebook=$result1;
			$this->view->google=$result2;
			$this->view->myspace=$result3;
			$this->view->others=$result4;
			
	}
	public function albumNoticesAction()
	{
	  		$memid = $_SESSION["sess_userid"];
			$is_user= Doctrine::getTable('AlbumNotifications')->getUserId($memid);
			//echo '<pre>';print_r($is_user);exit;
			if($is_user['numCount']!=0)
			{
			$result= Doctrine::getTable('AlbumNotifications')->getNotifications($memid);
			}
			else
			$result= Doctrine::getTable('AlbumNotifications')->getNotificationss($memid);
			
			//echo '<pre>';print_r($result);exit;
			$this->view->Notifications=$result;
			
	}
	public function saveNotificationsAction()
	{
			//echo '<pre>';print_r($_POST);exit;
			$memid = $_SESSION["sess_userid"];
			$result= Doctrine::getTable('AlbumNotifications')->getNotifications($memid);
			//echo '<pre>';print_r($result['user_id']);exit;
			if($result['user_id']== $_SESSION["sess_userid"])
			{
				//echo '<pre>';print_r($_POST);exit;
				$result= Doctrine::getTable('AlbumNotifications')->updateNotifications($memid,$_POST);
				
			}
			else
			{
				$result= Doctrine::getTable('AlbumNotifications')->addNotifications($memid,$_POST);
				
				
			}
			$this->_redirect("album/settings/album-notices");
					
	}
		public function changealbumSettingsAction()
	{
		$memid = $_SESSION["sess_userid"];
		//echo '<pre>';print_r($_POST);exit;
	  		$type = $_POST['type'];
			$action = $_POST['action'];
			if($type == 1)
			{
				$setting_type="Facebook";
			}
			else if($type == 2)
			{
				$setting_type="Google";
			}
			else if($type == 3)
			{
				$setting_type="MySpace";
			}
			else
			{
				$setting_type="Others";
			}
				$result= Doctrine::getTable('AlbumSettings')->getSettings($memid,$setting_type);
				if(count($result)!=0)
				{
					$result= Doctrine::getTable('AlbumSettings')->updateSettings($result['id'],$action);
				}
				else
				{
					$result= Doctrine::getTable('AlbumSettings')->addSettings($memid,$setting_type,$action);
				}
				$jsonData['output'] = $result;
				$this->_helper->json->sendJson($jsonData);	
			
	}
		
	
}	
